package com.steak.transaction.service;

import com.steak.transaction.datasource.DatasourceScope;
import com.steak.transaction.result.R;
import lombok.AllArgsConstructor;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

/**
 * @author 刘牌
 * @date 2022/3/19:49
 */
@Service
@AllArgsConstructor
public class OrderService {

    private JdbcTemplate jdbcTemplate;

    @DatasourceScope(scope = "slave1")
    public R saveOrder(Integer userId , Integer commodityId){
        String sql = "INSERT INTO `order`(user_id,commodity_id) VALUES("+userId+","+commodityId+")";
        jdbcTemplate.execute(sql);
        return R.builder().code(200).msg("save order success").build();
    }
}
